package com.ghca.myinfo3.system.controller;

import com.ghca.myinfo3.common.eneity.BJUIResponse;
import com.ghca.myinfo3.system.entity.Department;
import com.ghca.myinfo3.system.entity.User;
import com.ghca.myinfo3.system.service.IDepartmentService;
import com.ghca.myinfo3.system.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2016/12/18.
 */
@Controller()
@RequestMapping("/system/organization")
public class OrganizationController {


    @Resource
    private IDepartmentService departmentService;

    @Resource
    private IUserService userService;

    @RequestMapping
    public String organization() {
        return "system/organization";
    }

    @ResponseBody
    @RequestMapping("dept/list")
    public List<Department> listDepartment(@RequestParam(value = "parentId", required = false) Long parentId) {
        return departmentService.list(parentId);
    }


    @RequestMapping("user/list")
    @ResponseBody
    public List<User> listUser(@RequestParam(value = "deptId", required = false) Long deptId) {
        User user = new User();
        return userService.list(user);
    }
}
